<template>
  <el-form :model="ruleForm" :rules="accountRules" status-icon ref="ruleFormRef">
    <div class="task-title">
      <cpro-public title="任务名称" :show-stat="true">
        <template v-slot:content>
          <el-form-item prop="taskTitle" class="item">
            <el-input
              class="input"
              v-model="ruleForm.taskTitle"
              placeholder="请输入所要发布的任务的名称，如UI设计，后端代码书写等"
            />
          </el-form-item>
        </template>
      </cpro-public>
    </div>
  </el-form>
</template>

<script lang="ts" setup>
import { ref, reactive, defineEmits, defineExpose } from 'vue'
import cproPublic from '@/components/creat-projects/cpro-public.vue'
import { ElMessage } from 'element-plus'
import type { FormRules, FormInstance, ElForm } from 'element-plus'
const emit = defineEmits(['updataTitle'])
const ruleFormRef = ref<FormInstance>()
const ruleForm = reactive({
  taskTitle: ''
})
const accountRules: FormRules = {
  taskTitle: [{ required: true, message: '任务名不能为空哦~', trigger: 'blur' }]
}
const upLoadtaskTitle = (): Boolean => {
  if (ruleForm.taskTitle == '') {
    ElMessage({
      showClose: true,
      message: '请填写任务名称！！',
      type: 'error'
    })
    return false
  }
  emit('updataTitle', ruleForm.taskTitle)
  return true
}

defineExpose({ upLoadtaskTitle })
</script>

<style lang="less" scoped>
.task-title {
  .item {
    margin: 0 0 0 8px;
  }
  .input {
    border: 1px solid #e4e4e4;
    border-radius: 5px;
    width: 1069px;
    height: 40px;
    line-height: 40px;
    font-size: 13px;
  }
}
</style>
